/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.axiom.controller;

import com.axiom.persistence.StudentInfo_Persist;
import com.axiom.persistence.student_course_persist;
import com.axiom.utility.IdGenerator;
import com.axiom.vo.student_detail;
import org.hibernate.ScrollableResults;

/**
 *
 * @author Shuhail
 */
public class student_info_controller {
    
    public static student_info_controller getInstance() {
        
        return new student_info_controller();
    }
    
    public boolean insertFresh(student_detail detail) {
        
        return StudentInfo_Persist.getInstance().insertFresh(detail);
    }
    
    
    public String getStudentIDForCourse() {
        
        return StudentInfo_Persist.getInstance().getTheLastPK();
    }
    
    
    public ScrollableResults getStudNameCourseAndContact() {
        
        return StudentInfo_Persist.getInstance().getNameCourseAndPhone();
    }
    
    public ScrollableResults getStudentFeesDetails(String name) {
        
        return StudentInfo_Persist.getInstance().getStudentFeeDetails(name);
    }
    
    
    public int removeStudent(String studName) {
        
        int studDel = StudentInfo_Persist.getInstance().deleteRecord(studName);
        int studeCourse = student_course_persist.getInstance().deleteStudent(studName);
        
        if(studeCourse !=0 && studDel!=0) {
            return studeCourse;
        }
        else 
            return 0;
    }
    
    public String getStudentFeeDetailsBasedonId(String id) {
        
        ScrollableResults sr = StudentInfo_Persist.getInstance().getStudentFeeDetailsBasedonId(id);
        StringBuilder sb = new StringBuilder();
        while(sr.next()) {
            
            return sr.get(0).toString()+":::"+sr.get(1).toString()+":::"+sr.get(2).toString()+":::"+sr.get(3).toString();
            
            
        }
        System.out.println("SB  :"+sb.toString());
        return sb.toString();
    }
    
    public static void main(String[] args) {
        
        String s1 = new student_info_controller().getStudentFeeDetailsBasedonId("S1");
        System.out.println(s1);
    }
}
